﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.BlackApart.Data;

namespace blackhouse.BlackApart.Business.Calendar {
    internal class AvabilityOfApartmentTypes {

        private Dictionary<DateTime, int> freeDates = new Dictionary<DateTime, int>();

        public AvabilityOfApartmentTypes(IReservationDataAccess dataAccess, int groupId, DateTime fromDay, DateTime toDay) {
            Dictionary<DateTime,int> d = dataAccess.GetAvabilityOfApartmentType(groupId, fromDay, toDay);
            this.freeDates = new Dictionary<DateTime, int>();
            foreach (KeyValuePair<DateTime,int> item in d) {
                this.freeDates.Add(item.Key.Date, item.Value);
            }
        }

        internal int GetAvabilityForDay(DateTime day) {
            if (freeDates.ContainsKey(day.Date))
                return freeDates[day.Date];
            else
                return 0;
        }

    }
}
